package com.linsy.product.redis.mq.constant;

/**
 * 状态机
 */
public enum MqStatusEnum  {
    WAITING(10, "等待中"),
    RUNNING(15, "执行中"),
    RETRY_WAITING(20, "重试等待中"),
    RETRY_RUNNING(25, "重试执行中"),
    SUCCESS(100, "执行完成"),
    FAIL(99, "执行失败")
    ;

    private Integer status;

    private String val;

    MqStatusEnum(Integer status, String val) {
        this.status = status;
        this.val = val;
    }

    public Integer getStatus() {
        return status;
    }

    public String getVal() {
        return val;
    }

    public static MqStatusEnum find(Integer code) {
        if (code == null) {
            return null;
        }

        for (MqStatusEnum element : MqStatusEnum.values()) {
            if (element.getStatus().equals(code)) {
                return element;
            }
        }
        return null;
    }
}
